#!/bin/bash
#
# This hook is invoked by 'git-commit', and can be bypassed with --no-verify
# option. It takes a single parameter, the name of the file that holds the
# proposed commit log message. Exiting with non-zero status causes the
# 'git-commit' to abort.

wellformed=yes

subject=$(head -n 1 "$1")
if [ $(echo -n "${subject}"|wc -c) -gt 80 ]; then
  echo "** Git commit summary line shouldn't be longer than 80 characters." >&2
  wellformed=no
fi

if [ $(egrep -v '^#' "$1"|wc -l) -gt 1 ]; then
  if [[ -n "$(head -n 2 <$1|tail -n 1|tr -d [[:space:]])" ]]; then
    echo "** Git commit summary line should be separated from the body by a blank line." >&2
    wellformed=no
  fi
fi

if [ ${wellformed} != yes ]; then
  echo 'http://sysadmin.vazqueznanini.com.ar/puppet-commit-messages' >&2
	sleep 10
# exit 1
fi

exit 0
